<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:gui="clr-namespace:DentalGUIHelper;assembly=DentalConfig"
  xmlns:dentalConfig="clr-namespace:DentalConfig;assembly=DentalConfig"
  xmlns:converters="clr-namespace:DentalConfig.Converters;assembly=DentalConfig"
  xmlns:materialConverters="clr-namespace:MaterialDesignThemes.Wpf.Converters;assembly=MaterialDesignThemes.Wpf"
  xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf;assembly=MaterialDesignThemes.Wpf">
  <BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
  <converters:TrimmedToVisibilityConverter x:Key="TrimmedToVisibilityConverter"/>
  <gui:InverseBooleanConverter x:Key="invBool"/>
  <gui:InvertedBooleanToVisibilityConverter x:Key="invBoolToVis"/>
  <materialConverters:MathConverter x:Key="MathMultConverter" Operation="Multiply"/>
  <materialConverters:MathConverter x:Key="MathSubtractConverter" Operation="Subtract"/>

  <Style x:Key="DentalToolWindowHelpButtonStyle" TargetType="{x:Type gui:OnlineHelpButton}">
    <Setter Property="Background" Value="{DynamicResource TransparentWhiteBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type gui:OnlineHelpButton}">
          <Grid x:Name="grid" Background="{TemplateBinding Background}">
            <ContentPresenter
              x:Name="contentPresenter"
              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
              Margin="{TemplateBinding Padding}"
              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
              RecognizesAccessKey="False"
              Opacity="0.75"/>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
              <Setter TargetName="contentPresenter" Property="Opacity" Value="1"/>
              <Setter TargetName="grid" Property="Background" Value="{DynamicResource SemiTransparentWhiteBrush}"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="False">
              <Setter TargetName="contentPresenter" Property="Opacity" Value=".5"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
              <Setter Property="Visibility" Value="Collapsed"/>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <Style x:Key="HeaderToolTipGrid" TargetType="{x:Type Grid}">
    <Setter Property="Background" Value="Transparent"/>
    <Style.Triggers>
      <DataTrigger Binding="{Binding ToolTip, RelativeSource={RelativeSource Self}}" Value="{x:Null}">
        <Setter Property="Visibility" Value="Collapsed"/>
      </DataTrigger>
    </Style.Triggers>
  </Style>

  <ControlTemplate x:Key="OnlineHelpDefaultToolTip" >
    <StackPanel Orientation="Horizontal">
      <TextBlock Text="{gui:Translate ClickOnlineHelpNew}" Margin="0,0,4,0" VerticalAlignment="Center"/>
      <wpf:PackIcon Kind="HelpCircleOutline" Width="20" Height="20" VerticalAlignment="Center"/>
    </StackPanel>
  </ControlTemplate>

  <ControlTemplate x:Key="OfflineHelpDefaultToolTip" >
    <StackPanel Orientation="Horizontal">
      <TextBlock Text="{gui:Translate ClickOfflineHelp}" Margin="0,0,4,0" VerticalAlignment="Center"/>
      <wpf:PackIcon Kind="HelpCircleOutline" Width="20" Height="20" VerticalAlignment="Center"/>
    </StackPanel>
  </ControlTemplate>

  <ControlTemplate x:Key="DockingIndicatorVertical">
    <Grid x:Name="Indicator" Width="4" MinWidth="{Binding UnsnapNormalizedProgress.X, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type gui:DentalToolWindowBase}}, Converter={StaticResource MathMultConverter}, ConverterParameter=4, FallbackValue=0}" Margin="4,20" Background="{DynamicResource SecondaryAccentBrush}" RenderTransformOrigin="0.5,0.5">
      <Grid.RenderTransform>
        <TransformGroup>
          <ScaleTransform x:Name="ScaleTransform" ScaleX="1" ScaleY="0" />
        </TransformGroup>
      </Grid.RenderTransform>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="Tag" Value="{x:Static Visibility.Visible}">
        <Trigger.EnterActions>
            <BeginStoryboard>
                <Storyboard>
                  <DoubleAnimation Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform" From="0" To="1" Duration="0:0:0.3">
                    <DoubleAnimation.EasingFunction>
                      <SineEase EasingMode="EaseOut" />
                    </DoubleAnimation.EasingFunction>
                  </DoubleAnimation>
                  <DoubleAnimation Storyboard.TargetProperty="Width" Storyboard.TargetName="Indicator" From="4" To="4" Duration="0:0:0.0"/>
                  <DoubleAnimation Storyboard.TargetProperty="Width" Storyboard.TargetName="Indicator" From="4" To="0" BeginTime="0:0:1.5" Duration="0:0:0.3">
                    <DoubleAnimation.EasingFunction>
                      <SineEase EasingMode="EaseOut" />
                    </DoubleAnimation.EasingFunction>
                  </DoubleAnimation>
                </Storyboard>
            </BeginStoryboard>
        </Trigger.EnterActions>
        <Trigger.ExitActions>
            <BeginStoryboard>
                <Storyboard>
                    <Storyboard>
                      <DoubleAnimation Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform" From="1" To="0" Duration="0:0:0.6">
                        <DoubleAnimation.EasingFunction>
                          <SineEase EasingMode="EaseOut" />
                        </DoubleAnimation.EasingFunction>
                      </DoubleAnimation>
                      <DoubleAnimation Storyboard.TargetProperty="Width" Storyboard.TargetName="Indicator" From="4" To="4" Duration="0:0:0.0"/>
                    </Storyboard>
                </Storyboard>
            </BeginStoryboard>
        </Trigger.ExitActions>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <ControlTemplate x:Key="DockingIndicatorHorizontal">
    <Grid x:Name="Indicator" Height="4" MinHeight="{Binding UnsnapNormalizedProgress.Y, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type gui:DentalToolWindowBase}}, Converter={StaticResource MathMultConverter}, ConverterParameter=4, FallbackValue=0}" Margin="20,4" Background="{DynamicResource SecondaryAccentBrush}" RenderTransformOrigin="0.5,0.5">
      <Grid.RenderTransform>
        <TransformGroup>
          <ScaleTransform x:Name="ScaleTransform" ScaleX="0" ScaleY="1" />
        </TransformGroup>
      </Grid.RenderTransform>
    </Grid>
    <ControlTemplate.Triggers>
      <Trigger Property="Tag" Value="{x:Static Visibility.Visible}">
        <Trigger.EnterActions>
            <BeginStoryboard>
                <Storyboard>
                  <DoubleAnimation Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform" From="0" To="1" Duration="0:0:0.3">
                    <DoubleAnimation.EasingFunction>
                      <SineEase EasingMode="EaseOut" />
                    </DoubleAnimation.EasingFunction>
                  </DoubleAnimation>
                  <DoubleAnimation Storyboard.TargetProperty="Height" Storyboard.TargetName="Indicator" From="4" To="4" Duration="0:0:0.0"/>
                  <DoubleAnimation Storyboard.TargetProperty="Height" Storyboard.TargetName="Indicator" From="4" To="0" BeginTime="0:0:1.5" Duration="0:0:0.3">
                    <DoubleAnimation.EasingFunction>
                      <SineEase EasingMode="EaseOut" />
                    </DoubleAnimation.EasingFunction>
                  </DoubleAnimation>
                </Storyboard>
            </BeginStoryboard>
        </Trigger.EnterActions>
        <Trigger.ExitActions>
            <BeginStoryboard>
                <Storyboard>
                    <Storyboard>
                      <DoubleAnimation Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform" From="1" To="0" Duration="0:0:0.6">
                        <DoubleAnimation.EasingFunction>
                          <SineEase EasingMode="EaseOut" />
                        </DoubleAnimation.EasingFunction>
                      </DoubleAnimation>
                      <DoubleAnimation Storyboard.TargetProperty="Height" Storyboard.TargetName="Indicator" From="4" To="4" Duration="0:0:0.0"/>
                    </Storyboard>
                </Storyboard>
            </BeginStoryboard>
        </Trigger.ExitActions>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <ControlTemplate x:Key="ToolWindowBaseTemplate" TargetType="{x:Type gui:DentalToolWindowBase}">
    <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="Transparent">
      <Grid Background="Transparent">
        <AdornerDecorator>
          <GroupBox Name="WindowGroupBox" Style="{DynamicResource MaterialDesignRaisedCardGroupBox}" Margin="4" Padding="0">
            <GroupBox.Header>
              <!-- Title bar -->
              <DockPanel
                x:Name="PART_TitleBar"
                DockPanel.Dock="Top"
                Background="{DynamicResource ToolWindowTitleBrush}"
                Height="{Binding TitlebarHeight, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type gui:DentalToolWindowBase}}}"
                Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}">

                <!-- Close Button -->
                <Button
                  x:Name="PART_Close"
                  DockPanel.Dock="Right"
                  IsTabStop="False"
                  Width="24"
                  MinHeight="24"
                  Margin="0"
                  VerticalAlignment="Center"
                  Style="{DynamicResource MaterialDesignFlatButton}"
                  Background="{DynamicResource PrimaryHueMidBrush}"
                  Foreground="{DynamicResource PrimaryHueMidLightForegroundBrush}"
                  IsEnabled="{Binding DisableCloseButton, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type gui:DentalToolWindowBase}}, Converter={StaticResource invBool}}"
                  Visibility="{TemplateBinding ShowCloseButton, Converter={StaticResource BooleanToVisibilityConverter}}"
                  WindowChrome.IsHitTestVisibleInChrome="True">
                  <wpf:PackIcon Kind="CloseCircle"/>
                </Button>

                <!-- Restore Button -->
                <Button
                  x:Name="PART_Restore"
                  DockPanel.Dock="Right"
                  IsTabStop="False"
                  Width="24"
                  MinHeight="24"
                  Margin="0"
                  VerticalAlignment="Center"
                  Style="{DynamicResource MaterialDesignFlatButton}"
                  Background="{DynamicResource PrimaryHueMidBrush}"
                  Foreground="{DynamicResource PrimaryHueMidLightForegroundBrush}"
                  WindowChrome.IsHitTestVisibleInChrome="True">
                  <wpf:PackIcon Kind="WindowRestore"/>
                </Button>

                <!-- Maximize Button -->
                <Button
                  x:Name="PART_Max"
                  DockPanel.Dock="Right"
                  IsTabStop="False"
                  Width="24"
                  MinHeight="24"
                  Margin="0"
                  VerticalAlignment="Center"
                  Style="{DynamicResource MaterialDesignFlatButton}"
                  Background="{DynamicResource PrimaryHueMidBrush}"
                  Foreground="{DynamicResource PrimaryHueMidLightForegroundBrush}"
                  WindowChrome.IsHitTestVisibleInChrome="True">
                  <wpf:PackIcon Kind="WindowMaximize"/>
                </Button>

                <!-- Minimize Button -->
                <Button
                  x:Name="PART_Min"
                  DockPanel.Dock="Right"
                  IsTabStop="False"
                  Width="24"
                  MinHeight="24"
                  Margin="0"
                  VerticalAlignment="Center"
                  Style="{DynamicResource MaterialDesignFlatButton}"
                  Background="{DynamicResource PrimaryHueMidBrush}"
                  Foreground="{DynamicResource PrimaryHueMidLightForegroundBrush}"
                  WindowChrome.IsHitTestVisibleInChrome="True">
                  <wpf:PackIcon Kind="WindowMinimize"/>
                </Button>

                <!-- Help Button -->
                <Grid Background="Transparent" DockPanel.Dock="Right" DataContext="{Binding ElementName=PART_OnlineHelp}">
                  <Grid.Style>
                    <Style TargetType="{x:Type Grid}">
                      <Setter Property="ToolTip">
                        <Setter.Value>
                          <Control Template="{DynamicResource OnlineHelpDefaultToolTip}"/>
                        </Setter.Value>
                      </Setter>
                      <Style.Triggers>
                        <DataTrigger Binding="{Binding OpenManual}" Value="True">
                          <Setter Property="ToolTip">
                            <Setter.Value>
                              <Control Template="{DynamicResource OfflineHelpDefaultToolTip}"/>
                            </Setter.Value>
                          </Setter>
                        </DataTrigger>
                      </Style.Triggers>
                    </Style>
                  </Grid.Style>
                  <gui:OnlineHelpButton
                    x:Name="PART_OnlineHelp"
                    IsTabStop="False"
                    Width="24"
                    MinHeight="24"
                    Margin="0"
                    VerticalAlignment="Center"
                    Background="{DynamicResource PrimaryHueMidBrush}"
                    Foreground="{DynamicResource PrimaryHueMidForegroundBrush}"
                    Visibility="Collapsed"
                    WindowChrome.IsHitTestVisibleInChrome="True">
                    <wpf:PackIcon Kind="HelpCircleOutline"/>
                  </gui:OnlineHelpButton>
                </Grid>

                <!-- Header ToolTip Button -->
                <Grid Visibility="{Binding IsVisible, ElementName=PART_OnlineHelp, Converter={StaticResource invBoolToVis}}" DockPanel.Dock="Right" Margin="0" VerticalAlignment="Center">
                  <Grid
                    x:Name="PART_HeaderToolTip"
                    Width="24"
                    MinHeight="24"
                    WindowChrome.IsHitTestVisibleInChrome="True"
                    Style="{StaticResource HeaderToolTipGrid}">
                    <wpf:PackIcon Kind="InformationCircleOutline" Foreground="{DynamicResource PrimaryHueMidForegroundBrush}" Margin="4"/>
                  </Grid>
                </Grid>

                <!-- Window Title -->
                <Canvas Background="Transparent">
                  <Grid Height="{Binding Parent.ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" Width="{Binding Parent.ActualWidth, Mode=OneWay, RelativeSource={RelativeSource Self}}">
                    <TextBlock Text="{TemplateBinding Title}" TextTrimming="CharacterEllipsis" VerticalAlignment="Center" Margin="8 4 4 4" FontSize="16" Foreground="White">
                      <TextBlock.ToolTip>
                        <ToolTip Visibility="{Binding RelativeSource={RelativeSource Self}, Path=PlacementTarget, Converter={StaticResource TrimmedToVisibilityConverter}}">
                          <ToolTip.Content>
                            <TextBlock Text="{TemplateBinding Title}"/>
                          </ToolTip.Content>
                        </ToolTip>
                      </TextBlock.ToolTip>
                    </TextBlock>
                  </Grid>
                </Canvas>
              </DockPanel>
            </GroupBox.Header>
            <ScrollViewer x:Name="ContentScrollViewer" Background="{TemplateBinding Background}" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden">
              <!-- Window content -->
              <ContentPresenter/>
            </ScrollViewer>
          </GroupBox>
        </AdornerDecorator>
        <Grid x:Name="DockingIndicator" Opacity="0.8">
          <ContentControl Template="{StaticResource DockingIndicatorVertical}" x:Name="DockingIndicatorLeft" HorizontalAlignment="Left" Tag="{x:Static Visibility.Collapsed}"/>
          <ContentControl Template="{StaticResource DockingIndicatorVertical}" x:Name="DockingIndicatorRight" HorizontalAlignment="Right" Tag="{x:Static Visibility.Collapsed}"/>
          <ContentControl Template="{StaticResource DockingIndicatorHorizontal}" x:Name="DockingIndicatorTop" VerticalAlignment="Top" Tag="{x:Static Visibility.Collapsed}"/>
          <ContentControl Template="{StaticResource DockingIndicatorHorizontal}" x:Name="DockingIndicatorBottom" VerticalAlignment="Bottom" Tag="{x:Static Visibility.Collapsed}"/>
        </Grid>
        <ResizeGrip x:Name="WindowResizeGrip" HorizontalAlignment="Right" IsTabStop="false" Visibility="Collapsed" VerticalAlignment="Bottom"/>
      </Grid>
    </Border>
    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="ResizeMode" Value="NoResize"/>
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Max"/>
        <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Min"/>
        <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Restore"/>
        <Setter Property="IsEnabled" Value="False" TargetName="PART_Max"/>
        <Setter Property="IsEnabled" Value="False" TargetName="PART_Min"/>
        <Setter Property="IsEnabled" Value="False" TargetName="PART_Restore"/>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="WindowState" Value="Normal"/>
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Restore"/>
        <Setter Property="IsEnabled" Value="False" TargetName="PART_Restore"/>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="WindowState" Value="Normal"/>
          <Condition Property="gui:WindowContent.CanWindowContentScroll" Value="True"/>
        </MultiTrigger.Conditions>
        <Setter Property="MaxWidth" Value="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Width, Converter={StaticResource MathSubtractConverter}, ConverterParameter=50}" TargetName="ContentScrollViewer"/>
        <Setter Property="MaxHeight" Value="{Binding Source={x:Static SystemParameters.WorkArea}, Path=Height, Converter={StaticResource MathSubtractConverter}, ConverterParameter=50}" TargetName="ContentScrollViewer"/>
        <Setter Property="HorizontalScrollBarVisibility" Value="Auto" TargetName="ContentScrollViewer"/>
        <Setter Property="VerticalScrollBarVisibility" Value="Auto" TargetName="ContentScrollViewer"/>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="WindowState" Value="Maximized"/>
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Max"/>
        <Setter Property="IsEnabled" Value="False" TargetName="PART_Max"/>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="WindowState" Value="Minimized"/>
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" Value="Collapsed" TargetName="PART_Min"/>
        <Setter Property="IsEnabled" Value="False" TargetName="PART_Min"/>
        <Setter Property="HorizontalAlignment" Value="Left" TargetName="WindowGroupBox"/>
        <Setter Property="Width" Value="150" TargetName="WindowGroupBox"/>
      </MultiTrigger>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
          <Condition Property="WindowState" Value="Normal"/>
        </MultiTrigger.Conditions>
        <Setter Property="Visibility" TargetName="WindowResizeGrip" Value="Visible"/>
        <Setter Property="IsEnabled" TargetName="WindowResizeGrip" Value="False"/>
      </MultiTrigger>
      <Trigger Property="ShowTitleBar" Value="False">
        <Setter Property="Style" TargetName="WindowGroupBox" Value="{DynamicResource MaterialDesignRoundedRaisedCardGroupBox}"/>
        <Setter Property="Visibility" TargetName="DockingIndicator" Value="Collapsed"/>
      </Trigger>
      <!--Docking indicator left-->
      <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Inside'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Left'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
        </MultiDataTrigger.Conditions>
        <Setter Property="Tag" TargetName="DockingIndicatorLeft" Value="{x:Static Visibility.Visible}"/>
      </MultiDataTrigger>
      <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Outside'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Right'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
        </MultiDataTrigger.Conditions>
        <Setter Property="Tag" TargetName="DockingIndicatorLeft" Value="{x:Static Visibility.Visible}"/>
      </MultiDataTrigger>
      <!--Docking indicator right-->
      <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Inside'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Right'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
        </MultiDataTrigger.Conditions>
        <Setter Property="Tag" TargetName="DockingIndicatorRight" Value="{x:Static Visibility.Visible}"/>
      </MultiDataTrigger>
      <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Outside'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Left'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
        </MultiDataTrigger.Conditions>
        <Setter Property="Tag" TargetName="DockingIndicatorRight" Value="{x:Static Visibility.Visible}"/>
      </MultiDataTrigger>
      <!--Docking indicator top-->
      <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Inside'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Top'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
        </MultiDataTrigger.Conditions>
        <Setter Property="Tag" TargetName="DockingIndicatorTop" Value="{x:Static Visibility.Visible}"/>
      </MultiDataTrigger>
      <!--Docking indicator bottom-->
      <MultiDataTrigger>
        <MultiDataTrigger.Conditions>
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Inside'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
          <Condition Binding="{Binding Path=AnchorPositon, RelativeSource={RelativeSource Self}, Converter={converters:EnumFlagToBoolConverter FlagValue='Bottom'}, ConverterParameter={x:Type dentalConfig:AnchorPositon}}" Value="True" />
        </MultiDataTrigger.Conditions>
        <Setter Property="Tag" TargetName="DockingIndicatorBottom" Value="{x:Static Visibility.Visible}"/>
      </MultiDataTrigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <ControlTemplate x:Key="ToolWindowMaximizedTemplate" TargetType="{x:Type gui:DentalToolWindowBase}">
    <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="Transparent">
      <Grid Background="Transparent">
        <AdornerDecorator>
          <Grid Background="{TemplateBinding Background}">
            <!-- Window content -->
            <ContentPresenter/>
            <Grid DockPanel.Dock="Top" HorizontalAlignment="Right" VerticalAlignment="Top" Background="{DynamicResource ToolbarBackgroundBrush}">
              <gui:WindowCommands ShowMinButton="False"/>
            </Grid>
          </Grid>
        </AdornerDecorator>
      </Grid>
    </Border>
  </ControlTemplate>

  <!-- DentalToolWindowBase Style with own title bar -->
  <Style TargetType="{x:Type gui:DentalToolWindowBase}">
    <Setter Property="Background" Value="{DynamicResource ToolWindowBackgroundBrush}"/>
    <Setter Property="Foreground" Value="{DynamicResource ToolWindowForegroundBrush}"/>
    <Setter Property="AllowsTransparency" Value="True"/>
    <Setter Property="gui:WindowContent.CanWindowContentScroll" Value="False"/>
    <Setter Property="TitlebarHeight" Value="32"/>
    <Setter Property="TextElement.FontFamily" Value="{DynamicResource DefaultFont}"/>
    <Setter Property="Template" Value="{StaticResource ToolWindowBaseTemplate}"/>
    <Style.Triggers>
      <Trigger Property="WindowState" Value="Maximized">
        <Setter Property="Template" Value="{StaticResource ToolWindowMaximizedTemplate}"/>
      </Trigger>
    </Style.Triggers>
  </Style>

    <!-- DentalToolWindowBase Style without rounded corners and hidden titlebar -->
    <Style x:Key="FloatingWindowStyle" TargetType="{x:Type gui:DentalToolWindowBase}">
      <Setter Property="Background" Value="{DynamicResource ToolWindowBackgroundBrush}"/>
      <Setter Property="Foreground" Value="{DynamicResource ToolWindowForegroundBrush}"/>
      <Setter Property="BorderBrush" Value="{DynamicResource FloatingWindowBorderBrush}"/>
      <Setter Property="BorderThickness" Value="{DynamicResource FloatingWindowBorderThickness}"/>
      <Setter Property="AllowsTransparency" Value="False"/>
      <Setter Property="ShowTitleBar" Value="False"/>
      <Setter Property="TitlebarHeight" Value="32"/>
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="{x:Type gui:DentalToolWindowBase}">
            <Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="Transparent">
              <Grid Background="Transparent">
                <AdornerDecorator>
                  <GroupBox Name="WindowGroupBox" Margin="0" Padding="0">
                    <GroupBox.Header>
                      <!-- Title bar -->
                      <DockPanel
                        x:Name="PART_TitleBar"
                        DockPanel.Dock="Top"
                        Background="{DynamicResource ToolWindowTitleBrush}"
                        Height="{Binding TitlebarHeight, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type gui:DentalToolWindowBase}}}"
                        Visibility="{TemplateBinding ShowTitleBar, Converter={StaticResource BooleanToVisibilityConverter}}">
                        <Button x:Name="PART_Close" Visibility="Collapsed"/>
                        <Button x:Name="PART_Restore" Visibility="Collapsed"/>
                        <Button x:Name="PART_Maximize" Visibility="Collapsed"/>
                        <Button x:Name="PART_Minimize" Visibility="Collapsed"/>
                        <gui:OnlineHelpButton x:Name="PART_OnlineHelp" Visibility="Collapsed"/>
                      </DockPanel>
                    </GroupBox.Header>
                    <DockPanel Background="{TemplateBinding Background}">
                      <!-- Window content -->
                      <ContentPresenter Grid.Row="1"/>
                    </DockPanel>
                  </GroupBox>
                </AdornerDecorator>
              </Grid>
            </Border>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>

</ResourceDictionary>
